﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Xinkui.Entity.AutoGenerator;

namespace Xinkui.WebModel.Cache.View {
    public class CompanyInfoView {

        public CompanyInfoView() { }

        public static CompanyInfoView Convert(CompanyInfo_Entity dbCompany) {
            CompanyInfoView view = new CompanyInfoView();
            view.CompanyEntity = dbCompany;
            if (dbCompany != null) {
                view.Certificates = CertificateCache.List(dbCompany.CompanyID);
                view.UserEntity = UserInfoCache.ViewByCompany(dbCompany.CompanyID);
                view.Equipments = EquipmentInfoCache.List(dbCompany.CompanyID);

                var coutryInfo = CountryCache.Get(dbCompany.CountryID);
                if (coutryInfo != null) {
                    view.CountryName = coutryInfo.Name;
                    var province = ProvinceCache.Get(coutryInfo.CountryId, dbCompany.ProvinceID);
                    if (province != null) {
                        view.Province = province.Province_EN;
                        var city = CityCache.Get(dbCompany.ProvinceID, dbCompany.CityID);
                        if (city != null) {
                            view.City = city.City_EN;
                        }
                    }
                }

                view.ExportRatioName = DictCache.GetName((int)DictTypeEnum.ExportRatio, dbCompany.ExportRatio);
                view.NumberOfEmpoyeesName = DictCache.GetName((int)DictTypeEnum.NumberOfEmployees, dbCompany.NumberofEmployees);
                view.NumberofRDEmployeesName = DictCache.GetName((int)DictTypeEnum.NumberOfRdEmployees, dbCompany.NumberofRDEmployees);
                view.OwnershipTypeName = DictCache.GetName((int)DictTypeEnum.OwnerShipType, dbCompany.OwnershipType);
                view.RegisterCapitalName = DictCache.GetName((int)DictTypeEnum.MonenyRange, dbCompany.RegisterCapital);
                view.TotalAnnualSalesName = DictCache.GetName((int)DictTypeEnum.MonenyRange, dbCompany.TotalAnnualSales);
                view.BussinessTypeName = DictCache.GetName((int)DictTypeEnum.BusinessType, dbCompany.BussinessType);
            }
            return view;
        }

        public CompanyInfo_Entity CompanyEntity { get; private set; }

        public UserInfo_Entity UserEntity { get; private set; }

        public List<CompanyCertificate_Entity> Certificates { get; private set; }

        public List<EquipmentInfo_Entity> Equipments { get; private set; }

        /// <summary>
        /// 国家
        /// </summary>
        public string CountryName { get; set; }


        /// <summary>
        /// 省份
        /// </summary>
        public string Province { get; set; }


        /// <summary>
        /// 城市
        /// </summary>
        public string City { get; set; }


        /// <summary>
        /// 员工数量
        /// </summary>
        public string NumberOfEmpoyeesName { get; set; }


        /// <summary>
        /// I Don't know
        /// </summary>
        public string NumberofRDEmployeesName { get; set; }


        /// <summary>
        /// 注册资本
        /// </summary>
        public string RegisterCapitalName { get; set; }

        /// <summary>
        /// 年销售额
        /// </summary>
        public string TotalAnnualSalesName { get; set; }

        /// <summary>
        /// 出口比率
        /// </summary>
        public string ExportRatioName { get; set; }

        /// <summary>
        /// 所有权类型
        /// </summary>
        public string OwnershipTypeName { get; set; }

        /// <summary>
        /// 会员类型
        /// </summary>
        public string MemberTypeName { get; set; }

        /// <summary>
        /// 业务类型
        /// </summary>
        public string BussinessTypeName { get; set; }

    }
}
